package make.free.app.slide_puzzle;


import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

public class play extends Activity{
		ListView listview;
		String[] names={"Heo Con","Chuột Con","Voi Xinh","Trâu Cute",
				"Voi Con","Ngựa Con","Chó Xinh","Pikachu",
				"Sư tử","Hươu"
				};
				int[] images={R.drawable.map1,R.drawable.map2,R.drawable.map3,R.drawable.map4,R.drawable.map5,
						R.drawable.map6,R.drawable.map7,R.drawable.map8,R.drawable.map9,
						R.drawable.map10
				};
		@Override
		public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_play_list);
		listview =(ListView) findViewById(R.id.listView1);
		listview.setAdapter(new myAdapter(this,names));
		
		}
		
		class myAdapter extends ArrayAdapter{ 
			Context context;
			String[] names;
			public myAdapter(Context context,String[] names) {
			super(context,R.layout.activity_play_item,names);
			this.context=context;
			this.names=names;
			}
			@Override
			public View getView(int position, View convertView, ViewGroup parent) {
			// dùng LayoutInFlatter lấy đọc cấu trúc và nội dung của từng hàng ListView
			LayoutInflater inflater = (LayoutInflater)
			context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			View rowView = inflater.inflate(R.layout.activity_play_item, parent, false);
			// đi tìm trong từng hàng ListView, cập nhật thông tin
			TextView textView = (TextView) rowView.findViewById(R.id.name_map);
			ImageView imageView = (ImageView) rowView.findViewById(R.id.logo);
			textView.setText(names[position]);
			imageView.setImageResource(images[position]);
			return rowView;
			}
}
}
